﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CMS.BLL;
using CMS.BLL.Entity;

public partial class Controls_News_ctrNewsDetail : System.Web.UI.UserControl
{
    private int nCurrentLang = Support.GetCurrentLanguage();
    private int nDefaultLang = Support.GetDefaultLanguage();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadData();
        }
    }
    private void LoadData()
    {
        int nItemID = ConvertData.ConvertToInt(Request.QueryString[Config.NEWS_ID]);
        try
        {
            News objNews = new News();
            objNews.LoadById(nItemID);

            lblAuthor.Text = objNews.Data.Author;
            lblCreatedDate.Text = ConvertData.ConvertIntToDatetimeString(objNews.Data.CreatedDate);
            lblSource.Text = objNews.Data.Source;
            
            if (objNews.Data.Image != "")
                img.ImageUrl = Config.ROOT + Config.IMAGE_NEWS_DEFAULT_UPLOAD + objNews.Data.Image.ToString();
            else img.ImageUrl = Config.ROOT + "/Images/no_image.gif";

            switch (nCurrentLang)
            {
                case 1:
                    lblTitle.Text = objNews.Data.NewsTitle1;
                    ltrContent.Text = objNews.Data.MainContent1;
                    break;
                case 2:
                    lblTitle.Text = objNews.Data.NewsTitle2;
                    ltrContent.Text = objNews.Data.MainContent2;
                    break;
                case 3:
                    lblTitle.Text = objNews.Data.NewsTitle3;
                    ltrContent.Text = objNews.Data.MainContent3;
                    break;
            }
        }
        catch
        {
            Response.Redirect("~/Default.aspx");
        }
    }

}